using System;
using System.Collections.Generic;
using System.Text;

namespace Tools
{
    public class Util
    {

        public static void CheckObject(object obj)
        {
            if (obj == null) throw new Exception("object is null");
        }

        public static void CheckNonZero(double value)
        {
            if (value == 0) throw new Exception("value is 0");
        }

        public static void CheckPositive(double value)
        {
            if (value < 0) throw new Exception("value is negative");
        }

        public static void CheckNegative(double value)
        {
            if (value > 0) throw new Exception("value is positive");
        }

        public static void CheckString(string str)
        {
            if (string.IsNullOrEmpty(str.Trim())) throw new Exception("string is empty or null");
        }

        public static void CheckStringLength(string str, int minLength, int maxLength)
        {
            CheckObject(str);
            if (str.Length > maxLength) throw new Exception("string.Length > " + maxLength);
            if (str.Length < minLength) throw new Exception("string.Length < " + minLength);
        }

        public static void CheckRange(double value, double minimum, double maximum)
        {
            if (value < minimum) throw new Exception("value < " + minimum);
            if (value > maximum) throw new Exception("value > " + maximum);
        }

        public static void CheckPositiveNonZero(double value)
        {
            CheckNonZero(value);
            CheckPositive(value);
        }

    }
}
